package client.GUI;

import game.Player;
import game.client.Table;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;


import client.Client;
/**
 * Game frame.
 * @author SIIM
 *
 */
public class Window extends JFrame{
	private static final long serialVersionUID = -9192960755741717904L;
	private Client client;
	private Table table;
	private Player player;
	private Panel panel;
	private LoginWindow lw;
	private final Dimension DIM = new Dimension(1020, 580);
	private Dimension D;
	
	public Window(){
		setTitle("Poker");
		this.panel = new Panel(this);
		setDefaultCloseOperation(EXIT_ON_CLOSE);  
		D = Toolkit.getDefaultToolkit().getScreenSize();
		setSize(200, 100);
		setLocation((int) (D.getWidth() - this.getWidth()) / 2, (int) (D.getHeight() / 4));
		this.client = new Client(panel);
		this.lw = new LoginWindow(this, client);
		getContentPane().add(lw);
		lw.setVisible(true);
		this.panel.setClient(client);
	}
	/**
	 * Changes panels.
	 */
	public void changePanel(){
		this.player = new Player(client.getName(), Client.conf.getInitialMoney());
		this.table = new Table(player);
		panel.setPlayer(player);
		panel.setTable(table);
		client.start();
		setLocation(0, 0);
		this.getContentPane().removeAll();
		getContentPane().add(panel);
		this.setMinimumSize(DIM);
		this.setSize(DIM);
		panel.setVisible(true);
		this.validate();
		this.repaint();
	}
	/**
	 * Quit client.
	 */
	public void quit(){
		client.disconnect();
		this.dispose();
	}
	public static void main(String[] args) {
		Window w = new Window();
		w.setVisible(true);
	}
}
